package com.naive.imperative.view;

import java.util.Collection;

import com.naive.imperative.program.OperationBlock;

public class BlockRenderer extends OperationRenderer {
	private final OperationBlock block;

	public BlockRenderer(OperationBlock block) {
		super(null);
		this.block = block;
	}

	@Override
	public TapArea probe(float x, float y) {
		return null;
	}

	@Override
	public float getPreferredWidth(RenderingContext rc) {
		float result = 0;
		for (OperationRenderer o : getRenderers()) {
			result = Math.max(result, o.getPreferredWidth(rc));
		}
		return result;
	}

	@Override
	public float getPreferredHeight(RenderingContext rc) {
		float result = 0;
		for (OperationRenderer o : getRenderers()) {
			result += o.getPreferredHeight(rc);
		}
		return result;
	}

	@Override
	public void draw(RenderingContext c) {
		drawChildren(c);
	}

	@Override
	protected void doLayout(LayoutContext lc) {
		lc.indent();
		for(OperationRenderer r:getRenderers()) {
			lc.append(r);
			lc.newLine();
		}
	}

}
